﻿@using CJAtech.BBS.DataEntity;
@{
    Layout = null;
    if (Model == null)
    {
        this.CreateHttp404Result();
    }
}
@model CategoryInfo

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="format-detection" content="telephone=no,email=no">
    <title>知识宝典</title>
    <!-- 基础css begin -->
    <link type="text/css" rel="stylesheet" href="/Content/BenzXH/pkg/css/base.css">
    <!-- 基础css end -->
    <!-- 组件依赖css begin -->
    <!-- 组件依赖css end -->
    <!-- 页面css begin -->
    <link type="text/css" rel="stylesheet" href="/Content/BenzXH/pkg/css/layout.css">
    <link type="text/css" rel="stylesheet" href="/Content/BenzXH/css/cherry.css">
    <!-- 页面css begin -->
    <script type="text/javascript" charset="utf-8" src="/Content/BenzXH/pkg/js/core.js"></script>
    <script src="/Content/benzxh/js/scroll/scrollpagination.js?ver=201512071548"></script>
    <script src="/Content/benzxh/js/common.js?ver=201511261333"></script>
    <style>
        #wrapper {
            margin-top: 70px;
        }
    </style>
</head>
<body>
    <div class="background-full" style="background-image:url(/Content/BenzXH/images/lmsbg.png);"></div>
    <div id="wrapper">
        <div id="articlewrapper">
            <div class="transparent-bg top-know"><span class="margin-left block middle">@Model.CategoryName</span></div>
            @*<div class="transparent-bg padding-10-20 margin-top-8">
                    <p>全领域，尽情横--新一代梅赛德斯-奔驰-GLE SUV夺目上市</p>
                    <div class="margin-top-15">
                        <div class="block"><img src="/Content/BenzXH/images/find.png" alt="" class="width-icon"> 106 <img src="/Content/BenzXH/images/icon-ambia.png" alt="" class="width-icon"> 33</div>
                        <div class="block right padding-top-8">2015-10-19</div>
                    </div>
                </div>*@
        </div>
        <div id="loadingText" class="text-center">正在加载...</div>
        @*<button id="article_more" type="button" class="default-button margin-top-20 width-full" onclick="BindArticles(10)" style="display: none;">更多</button>*@
    </div>
    <script type="text/javascript">
        var pageIndex = 1;
        BindArticles(10);
        function BindArticles(pageSize) {
            pageSize = pageSize || 10;
            $("#articlewrapper").scrollPagination({
                //contentPage: "/benzxh/getarticlelist?categoryId=8&pageIndex=" + pageIndex + "&pageSize=" + pageSize,
                contentData: {},
                scrollTarget: $(window),
                heightOffset: 10,
                beforeLoad: function (options) {
                    $("#loadingText").show();
                    options.contentPage = "/lmsbbs/getarticlelist?categoryId=@Model.CategoryId&pageIndex=" + pageIndex + "&pageSize=" + pageSize;
                },
                appendItems: function (objInvokeResult) {
                    $("#loadingText").hide();

                    if (objInvokeResult.ResultCode == "ArticleInfoNull") {
                        //todo：移除更多事件
                        $("#article_more").removeAttr("onclick");
                        $("#article_more").hide();
                        //停止滚动加载
                        $("#articlewrapper").stopScrollPagination();
                        return;
                    }
                    if (objInvokeResult.ResultCode != "Success") {
                        alert(objInvokeResult.ResultMessage);
                        return;
                    }
                    if (objInvokeResult.Data.length < pageSize) {
                        //停止滚动加载
                        $("#articlewrapper").stopScrollPagination();
                        $("#article_more").removeAttr("onclick");
                        $("#article_more").hide();
                    } else {
                        //$("#article_more").show();
                    }
                    var html = "";
                    $.each(objInvokeResult.Data, function (i, objArticleResultInfo) {
                        html += CreateArticleHtml(objArticleResultInfo);
                    });

                    $("#articlewrapper").append(html);

                    pageIndex++;
                },
                afterLoad: function (objInvokeResult) {

                }
            });
        }
        function CreateArticleHtml(objArticleResultInfo) {
            var html = "";
            if (typeof (objArticleResultInfo) == "undefined") {
                return html;
            }
            html =
            '<div class="transparent-bg padding-10-20 margin-top-8" onclick="window.location.href=\'/lmsbbs/article/thread-article2/' + objArticleResultInfo.ArticleInfo.ArticleId + '\'">' +
                '<p>' + objArticleResultInfo.ArticleInfo.ArticleTitle + '</p>' +
                '<div class="margin-top-15">' +
                    '<div class="block"><img src="/Content/BenzXH/images/find.png" alt="" class="width-icon" style="width: 36%;"> ' + objArticleResultInfo.ArticleInfo.ViewCount + '</div>' +
                    '<div class="block right padding-top-8">' + JsonToDate(objArticleResultInfo.ArticleInfo.ApproveDate, false) + '</div>' +
                '</div>' +
            '</div>';
            return html;
        }
    </script>
</body>
</html>